<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
            <meta name="apple-mobile-web-app-capable" content="yes"/>
        </f:facet>
        <h:outputStylesheet library="css" name="main.css"/>
        <h:outputScript library="js" name="main.js"/>
        <ui:insert name="head">
            <title>FASTJSF</title>
        </ui:insert>
    </h:head>
    <h:body>
        <ui:insert name="menu">
            <ui:include src="/menu.xhtml"/>
        </ui:insert>

        <h:form id="fm" class="mainfm">
            <ui:insert name="form">
                <p:clock pattern="yyyy.MM.dd HH:mm:ss " mode="server" />
            </ui:insert>
            <h2>用户管理
            </h2>
            <p:separator /> 
            <p:growl id="growl" showDetail="true" sticky="true" /> 
            <p:layout style="min-width:400px;min-height:600px;">
                <p:layoutUnit position="north" size="45">
                    <p:commandButton value="新建" onclick="PF('addDlg').show();"/>
                </p:layoutUnit>


                <p:layoutUnit position="center">
                    <p:dataTable var="user" value="#{userView.userList}" widgetVar="table"
                                 emptyMessage="无数据" filteredValue="#{userView.filterUser}">

                        <f:facet name="header">
                            
                        </f:facet>

                        <p:column filterBy="#{user.userid}" headerText="Id" filterMatchMode="contains">
                            <h:outputText value="#{user.userid}" />
                        </p:column>
                        
                        <p:column filterBy="#{user.username}" headerText="username" filterMatchMode="contains">
                            <h:outputText value="#{user.username}" />
                        </p:column>
                        
                        <p:column filterBy="#{user.createtime}" headerText="createtime" filterMatchMode="contains">
                            <h:outputText value="#{user.createtime}" />
                        </p:column>
                        
                        <p:column filterBy="#{user.isactive}" headerText="isactive" filterMatchMode="contains">
                            <h:outputText value="#{user.isactive}" />
                        </p:column>
                        
                        <p:column filterBy="#{user.usertype}" headerText="usertype" filterMatchMode="contains">
                            <h:outputText value="#{user.usertype}" />
                        </p:column>
                    </p:dataTable>

                </p:layoutUnit>
            </p:layout>
            
            <p:dialog header="添加人员" widgetVar="addDlg" focus="username" >
                <h:panelGrid columns="4" cellpadding="5">
                    
                    <h:outputLabel for="username" value="人员名称:" />
                    <p:inputText id="username" label="username" value="#{userView.user.username}"/>

                    <h:outputLabel for="userlink" value="人员联系方式:" />
                    <p:inputText id="userlink" label="userlink" value="#{userView.user.userlink}"/>

                    <h:outputLabel for="remark" value="人员备注:" />
                    <p:inputText id="remark" label="remark" value="#{userView.user.remark}"/>
                    
                   <p:outputLabel for="type" value="人员类型:" />
                   <p:selectOneMenu id="type" value="#{userView.user.usertype}" style="width:125px">
                       <f:selectItem itemLabel="选择人员类型" itemValue="未选" />
                       <f:selectItem itemLabel="管理员" itemValue="管理员" />
                       <f:selectItem itemLabel="普通" itemValue="普通" />
                   </p:selectOneMenu> 
                    <p:outputLabel for="status" value="人员状态:" />
                    
                    <p:selectOneMenu id="status" value="#{userView.user.isactive}" style="width:125px">
                        <f:selectItem itemLabel="选择人员状态" itemValue="未选" />
                        <f:selectItem itemLabel="激活" itemValue="true" />
                        <f:selectItem itemLabel="废除" itemValue="false" />
                    </p:selectOneMenu>

                    <p:commandButton value="添加" type="submit" actionListener="#{userView.create()}"  update="fm" />

                </h:panelGrid>
            </p:dialog>
            
            <ui:insert name="growl">
                <p:growl globalOnly="true" showDetail="true" sticky="true">
                    <p:autoUpdate/>
                </p:growl>
            </ui:insert>

            <!-- 禁用掉输入框默认的回车提交事件 -->
            <p:commandButton id="my_dftCmdBtn" type="button" style="position: fixed;bottom: 0;right: 0;visibility: hidden;"/>
            <p:defaultCommand target="my_dftCmdBtn"/>
        </h:form>

        <ui:insert name="outer"/>
        <p:tooltip position="left"/>
        <p:confirmDialog id="cfmDlg" styleClass="cfmDlg" global="true" closeOnEscape="true" header="确认框" responsive="true">
            <p:commandButton value="确定" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
            <p:commandButton value="取消" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
        </p:confirmDialog>
    </h:body>
</html>
